<!DOCTYPE html>
<html lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
	xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="/layui/css/layui.css">
<link rel="stylesheet" href="/css/custom.form.css">
<style type="text/css">
.layui-disabled, .layui-disabled:hover {
    color: #000000!important;
    cursor: not-allowed!important;
}

.layui-form-label {
	width: 100px;
}

.layui-input-block {
	margin-left: 130px;
}

.layui-input layui-unselect {
	cursor: pointer;
}

.layui-table {
	width: 96%;
}
</style>
</head>
<body>
	<div class="panel panel-default operation" hidden>
		<div class="panel-heading title"></div>
		<div class="layui-tab">
			<div class="layui-tab-content">
				<div class="layui-tab-item layui-show">
					<div class="layui-card-body">
						<form class="layui-form" action="" lay-filter="info">
							<input name="_tabKey" id="_tabKey" hidden>
							<input name="_jcajxxuuid" id="_jcajxxuuid" hidden>
							<input name="_id" id="_id" hidden>
							
							<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
								<legend>案件信息</legend>
							</fieldset>
				
							<div class="layui-form-item">
								<label class="layui-form-label">案件名称</label>
								<div class="layui-input-inline">
									<input type="text" id="ajmc" name="ajmc"
										class="layui-input layui-disabled" disabled="ture">
								</div>
								
								<label class="layui-form-label">检查项目</label>
								<div class="layui-input-inline">
									<input type="text" id="jcxm" name="jcxm"
										class="layui-input layui-disabled" disabled="ture">
								</div>
							</div>
							<div class="layui-form-item">	
								<label class="layui-form-label">检查人</label>
								<div class="layui-input-inline">
									<input type="text" id="jcry" name="jcry"
										class="layui-input layui-disabled" disabled="ture">
								</div>
							</div>
							<div class="layui-form-item">	
								<label class="layui-form-label">纳税人名称</label>
								<div class="layui-input-inline">
									<input type="text" id="nsrmc" name="nsrmc"
										class="layui-input layui-disabled" disabled="ture">
								</div>
								<label class="layui-form-label">纳税人识别号</label>
								<div class="layui-input-inline">
									<input type="text" id="nsrsbh" name="nsrsbh"
										class="layui-input layui-disabled" disabled="ture">
								</div>
							</div>
							
							<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
								<legend>督办点</legend>
							</fieldset>
								
							<div class="layui-form-item">
								<label class="layui-form-label">督办点</label>
								<div class="layui-input-block">
									<textarea rows="3" name="details" id="details"
										placeholder="" autocomplete="off"
										class="layui-textarea layui-disabled" disabled="ture">金税三期两书未出具</textarea>
								</div>
							</div>
							
							<div class="layui-form-item">
								<div class="layui-input-block">
									<button type="submit" class="layui-btn" id="heal"
										onclick="return false" lay-submit lay-filter="heal">处理</button>
									
									<button type="submit" class="layui-btn" id="healNo"
										onclick="return false" lay-submit lay-filter="healNo">忽略</button>
									
									<button class="layui-btn layui-btn-primary" id="btn_cancel">返回</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="layui-tab table_div">
		<ul class="layui-tab-title">
			<li class="layui-this" id="unread" >未处理</li>
			<li id="read" >已处理</li>
		</ul>
		
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
				<div id="searchParam" >
					<div class="layui-form-item">
						
					</div>
					<table class="layui-table" id="unreadShowTable" lay-filter="unreadShowTable"></table>
				</div>
			</div>
			
			<div class="layui-tab-item">
				<div id="searchParam" >
					<div class="layui-form-item">
					</div>
					<table class="layui-table" id="readShowTable" lay-filter="readShowTable"></table>
				</div>
			</div>
		</div>
	</div>
	
	
	<div id="healDiv" class="demo-transfer" style="display: none">
		<div class="layui-form" action="">
			<div class="layui-form-item" style="margin-top: 5px">
				<label class="layui-form-label" style="">填写处理内容</label>
				<div class="layui-input-block">
					<textarea rows="2" name="healContent" id="healContent"
						placeholder="请输入处理原因,1-500个字符" autocomplete="off"
						class="layui-textarea"></textarea>
				</div>
			</div>
		</div>
	</div>
	
	
	<div id="healNoDiv" class="demo-transfer" style="display: none">
		<div class="layui-form" action="">
			<div class="layui-form-item" style="margin-top: 5px">
				<label class="layui-form-label" style="">填写忽略内容</label>
				<div class="layui-input-block">
					<textarea rows="2" name="healNoContent" id="healNoContent"
						placeholder="请输入忽略原因,1-500个字符" autocomplete="off"
						class="layui-textarea"></textarea>
				</div>
			</div>
		</div>
	</div>
	
	
	
	<script type="text/html" id="tool">
		<a class="layui-btn layui-btn-xs" lay-event="view">处理</a>
	</script>
	
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script>
	// 获取token
	var token = CoreUtil.getData("access_token");
	// 地址栏转义token中的#号
	var tokenQuery = token.replace("#", "%23");

	var readShowTable;
	var unreadShowTable;
	
	var table = layui.table;
	var form = layui.form;
	var layer = layui.layer;
	var $ = jQuery = layui.jquery;
	var laydate = layui.laydate;
	var upload = layui.upload;
	var element = layui.element;
	var maxlength = 500;
	var inspectionMan = "";
	var mold = "";
	var contentdate = null;
	
	
	layui.use([ 'table', 'layer', 'laydate', 'upload', 'element' ], function() {
		
		
		// 未处理
		unreadShowTable = table.render({
			elem : '#unreadShowTable',
			contentType : 'application/json',
			headers : {
				"authorization" : token
			},
			page : true // 开启分页
			,
			url : '/workflow/control/unheallist1' //数据接口
			,
			method : 'POST',
			parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
				return {
					"code" : res.code, //解析接口状态
					"msg" : res.msg, //解析提示文本
					"count" : CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
					"data" : CoreUtil.isEmpty(res.data) ? null
							: CoreUtil.paramsDecrypt(res.data.records)
				}
			},
			
			cols : [ [
			          {
			        	  align : 'center',
			        	  width : 230,
			        	  field : 'id',
			        	  title : '督办编号',
			        	  sort : true,
			          }, {
							align : 'center',
							width : 158,
							field : 'controlName',
							title : '督办名称',
							sort : true,
					  }, {
							align : 'center',
							width : 451,
							field : 'details',
							title : '督办详情',
							sort : true,
					  }, {
							align : 'center',
							width : 168,
							field : 'createTime',
							title : '督办日期',
							sort : true,
					  }, {
							fixed : 'right',
							align : 'center',
							width : 95,
							toolbar : "#tool",
							title : '操作'
					  },
			          ] ],
			toolbar : '#logToolbar'
		});

		// 列操作
		table.on('tool(unreadShowTable)', function(obj) {
			var data = obj.data;
			switch (obj.event) {
			case 'view':
				view(data, "0");
				break;
			}
		});
		
		
		// 列操作
		table.on('tool(unreadShowTable)', function(obj) {
			var data = obj.data;
			switch (obj.event) {
			case 'view':
				view(data, "0");
				break;
			}
		});
		
		
		// 已读
		readShowTable = table.render({
			elem : '#readShowTable',
			contentType : 'application/json',
			headers : {
				"authorization" : token
			},
			page : true // 开启分页
			,
			url : '/workflow/control/heallist1' //数据接口
			,
			method : 'POST',
			parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
				return {
					"code" : res.code, //解析接口状态
					"msg" : res.msg, //解析提示文本
					"count" : CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
					"data" : CoreUtil.isEmpty(res.data) ? null
							: CoreUtil.paramsDecrypt(res.data.records)
				}
			},
			
			cols : [ [
			          {
			        	  align : 'center',
			        	  width : 230,
			        	  field : 'id',
			        	  title : '督办编号',
			        	  sort : true,
			          }, {
							align : 'center',
							width : 158,
							field : 'controlName',
							title : '督办名称',
							sort : true,
					  }, {
							align : 'center',
							width : 288,
							field : 'ajmc',
							title : '案件名称',
							sort : true,
					  }, {
							align : 'center',
							width : 188,
							field : 'nsrmc',
							title : '纳税人名称',
							sort : true,
					  }, {
			        	  align : 'center',
			        	  width : 230,
			        	  field : 'relevance',
			        	  title : '关联编号',
			        	  sort : true,
			          }, {
							align : 'center',
							width : 168,
							field : 'createTime',
							title : '创建日期',
							sort : true,
					  }
			          ] ],
			toolbar : '#logToolbar'
		});

		// 列操作
		table.on('tool(readShowTable)', function(obj) {
			var data = obj.data;
			switch (obj.event) {
			case 'view':
				view(data, "0");
				break;
			}
		});
		
		
		// 列操作
		table.on('tool(readShowTable)', function(obj) {
			var data = obj.data;
			switch (obj.event) {
			case 'view':
				view(data, "0");
				break;
			}
		});
		
		// 返回
		$("#btn_cancel").click(function() {
			back();
			return false;
		});
		
		form.on('submit(heal)', function(data) {
			
			layer.open({
				type : 1,
				offset : '50px',
				skin : 'layui-layer-molv',
				title : "处理",
				area : [ '500px', '320px' ],
				shade : 0,
				shadeClose : false,
				content : jQuery("#healDiv"),
				btn : [ '处理', '取消' ],
				yes : function(index) {
					var _id = $('#_id').val();
					
					var mapArr = {
						'id' : _id,
						'controlIs' : 'Y',
						'controlContent' : $('#healContent').val(),
						'controlHeal' : '1'
					};

					CoreUtil.sendPost("/workflow/control/head", mapArr,
						function(res) {
							if (res.code == '0') {
								layer.msg("成功 处理！");
								back();
								return false;
							} else {
								layer.msg(res.msg);
								return false;
							}
						});
					layer.close(index);
				}
			});

		});
		
		
		// 推送人员
		form.on('submit(healNo)', function(data) {
			
			layer.open({
				type : 1,
				offset : '50px',
				skin : 'layui-layer-molv',
				title : "忽略",
				area : [ '500px', '320px' ],
				shade : 0,
				shadeClose : false,
				content : jQuery("#healNoDiv"),
				btn : [ '忽略', '取消' ],
				yes : function(index) {
					var _id = $('#_id').val();
					
					var mapArr = {
						'id' : _id,
						'controlIs' : 'N',
						'controlContent' : $('#healNoContent').val(),
						'controlHeal' : '1'
					};

					CoreUtil.sendPost("/workflow/control/head", mapArr,
						function(res) {
							if (res.code == '0') {
								layer.msg("成功 忽略！");
								back();
								return false;
							} else {
								layer.msg(res.msg);
								return false;
							}
						});
					layer.close(index);
				}
			});

		});
		
			
	});
	
	function search() {
		unreadShowTable.reload({
			where : {
			},
			page : {
				curr : 1
			}
		});
	};

	function view(data,id){
		var _id = data.id;
		$("#_id").val(_id);
		var stateCode = data.stateCode;
		$(".title").html("案件编号：" + data.jcajbh);
		$("#ajmc").val(data.ajmc);
		$("#jcxm").val(data.jcxm);
		$("#nsrmc").val(data.nsrmc);
		$("#nsrsbh").val(data.nsrsbh);
		$("#jcry").val(data.jcry);
		$("#details").val(data.details);
		var _fjdz = data.fjdz;
		if (!CoreUtil.isEmpty(_fjdz)) {
			$("#fjdz").val(_fjdz);
			var fjdzArr = _fjdz.split(",");
			var tmp = "<table class='layui-table'><tbody>";
			for (var i = 0;i<fjdzArr.length;i++) {
				var _fjdz = '"' + fjdzArr[i] + '"';
				var _i = i + 1;
				tmp += "<tr><td>附件" + _i + "</td><td>"
						+ "<a class='layui-btn layui-btn-xs' onclick='yjyl("
						+ _fjdz + ")'>一键预览</a>"
						+ "<a class='layui-btn layui-btn-xs' onclick='yjfz("
						+ _fjdz + ")'>一键复制</a>" + "</td></tr>";
			}
			tmp += "</tbody></table>";
			$("#fjdzDiv").html(tmp);
		} else {
			$("#fjdzDiv").html("未传附件");
		};
		// 查询办理流程
		// activityRecordDiv(data.jcajxxuuid);
		$("#pushHearMan21").hide();
		
		$(".table_div").hide();
		$(".operation").show();
		
		// read(_id);
		
	};
	
	function heal(_id){
		var mapArr = {
			'controlRead' : '1',
			'id' : _id
		};

		CoreUtil.sendPost("/workflow/control/heal", mapArr,
			function(res) {
				if (res.code == '0') {
					layer.msg("处理成功！");
					return false;
				} else {
					layer.msg(res.msg);
					return false;
				}
		});
			
	}
	
	function back() {
		search();
		$(".table_div").show();
		$(".operation").hide();
	}
	
	
	function activityRecordDiv(jcajxxuuid){
		$("#activityRecordDiv").html("");
		var mapArr = {
			relevance : jcajxxuuid
		};
		
		CoreUtil.sendPost("/workflow/activity/record", mapArr, function(res) {
			if (res.code == '0') {
				var data = res.data;
				if (!CoreUtil.isEmpty(data)) {
					
					var tmp = "<table class='layui-table'><tbody><tr>"
							+ "<td>序号</td>"
							+ "<td>处理时间</td>"
							+ "<td>状态</td>"
							+ "<td>处理人</td>"
							+ "<td>内容</td>"
							+ "<td>备注</td>"
							
					for (var i in data) {
						var content = "暂无";
						if(!CoreUtil.isEmpty(data[i].content)){
							content = data[i].content;
						}
						
						tmp += "<tr><td>" + i + "</td>"
								+ "<td>" + data[i].createTime + "</td>"
								+ "<td>" + data[i].stateName + "</td>"
								+ "<td>" + data[i].currentMan + "</td>"
								+ "<td>" + content + "</td>"
								+ "<td>" + data[i].remark + "</td>"

					}
					tmp += "</tbody></table>";
					$("#activityRecordDiv").html(tmp);
				} else {
					$("#activityRecordDiv").html("暂无流程");
				}
				
			} else {
				// layer.msg(res.msg);
				return false;
			}
		});
		
	};
	
</script>

</body>
</html>